package com.park.web.controller;

import com.park.web.base.baseOperation.BaseController;
import com.park.web.common.enumOrgType;
import com.park.web.core.wrapper.WrapMapper;
import com.park.web.core.wrapper.Wrapper;
import com.park.web.service.pbaParkingOrganizationInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(value = "WEB - pbaParkingOrganizationInfoController", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "OrganizationInfo", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class pbaParkingOrganizationInfoController extends BaseController {

    @Autowired
    pbaParkingOrganizationInfoService ipbaParkingOrganizationInfoService;

    @GetMapping("/selectOrganizationTree")
    @ApiOperation(value = "获取所有组织结构树", notes = "获取所有组织结构树")
    public Wrapper selectOrganizationTree() {
        var list = ipbaParkingOrganizationInfoService.selectAllList(null);
        return WrapMapper.okWithoutMessage(list);
    }

    @GetMapping("/selectParkTree")
    @ApiOperation(value = "获取所有车场组织结构树", notes = "获取所有车场组织结构树")
    public Wrapper selectParkTree() {
        var list = ipbaParkingOrganizationInfoService.selectAllList(enumOrgType.park.toString());
        return WrapMapper.okWithoutMessage(list);
    }

    @GetMapping("/selectByOrgCode/{orgCode}")
    @ApiOperation(value = "获取所有车场组织结构树", notes = "获取所有车场组织结构树")
    public Wrapper selectByOrgCode(@PathVariable("orgCode") String orgCode) {
        var list = ipbaParkingOrganizationInfoService.selectAllList(enumOrgType.park.toString());
        return WrapMapper.okWithoutMessage(list);
    }

    @GetMapping("/selectAllOrganization")
    @ApiOperation(value = "获取所有组织结构树，不包含设备)", notes = "获取所有组织结构树，不包含设备")
    public Wrapper selectAllOrganization() {
        var list = ipbaParkingOrganizationInfoService.selectAllOrganization();
        return WrapMapper.okWithoutMessage(list);
    }
}
